# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: Hans Janssen <janserv@gmail.com>
# Contributor: my64 <packages@obordes.com>
# Contributor: Colin Pitrat <colin.pitrat@gmail.com>

pkgname=openscenegraph
pkgver=3.6.5
pkgrel=22
pkgdesc='Open Source, high performance real-time graphics toolkit'
url='http://www.openscenegraph.org'
arch=('loong64' 'x86_64')
license=('custom:OSGPL')
depends=('fontconfig' 'libglvnd' 'libxinerama' 'libxrandr')
makedepends=('cmake' 'ffmpeg4.4' 'gdal' 'gst-plugins-base-libs' 'jasper' 'librsvg' 'libvncserver' 'openexr' 'poppler-glib')
optdepends=('ffmpeg4.4' 'gdal' 'gst-plugins-base-libs' 'jasper' 'librsvg' 'libvncserver' 'openexr' 'poppler-glib')
conflicts=('openthreads')
provides=('openthreads')
source=(https://github.com/openscenegraph/OpenSceneGraph/archive/OpenSceneGraph-${pkgver}.tar.gz
        openscenegraph-openexr3.patch
        ffmpeg4.4.patch)
sha256sums=('aea196550f02974d6d09291c5d83b51ca6a03b3767e234a8c0e21322927d1e12'
            '680ea7cd1b1681fb42137dd1510c64862507b889286d8788d3f017d9d307792d'
            '64a492d266e49aec611fd609251fa7dd08f75e86b25120a1abaf0328223c921a')
sha512sums=('7002fa30a3bcf6551d2e1050b4ca75a3736013fd190e4f50953717406864da1952deb09f530bc8c5ddf6e4b90204baec7dbc283f497829846d46d561f66feb4b'
            '0788e87bf17adf586d5041c5b565d0a09fe38f7c5e96a843e69f5171737aef68bd277b240ccf860cfb78e36ea6d7d7c599ecff104bb78de513d1b3edb70358ef'
            '9c6d63d3e38a4045b891ccf2f0a2876a52ce8b033214ef9a24072e2ebcde4d1ce12be6d420a37e3b2cb0bdbd5d7d5a808c45d3b207c20a54cfa1114dcfcd1ada')

prepare() {
  cd OpenSceneGraph-OpenSceneGraph-${pkgver}
  patch -p1 < ../openscenegraph-openexr3.patch # Fix build with openEXR 3
  patch -p1 < ../ffmpeg4.4.patch # Find ffmpeg 4.4 headers
}

build() {
  mkdir -p OpenSceneGraph-OpenSceneGraph-${pkgver}/build
  cd OpenSceneGraph-OpenSceneGraph-${pkgver}/build
  export PKG_CONFIG_PATH='/usr/lib/ffmpeg4.4/pkgconfig'
  cmake \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_BUILD_TYPE=Release \
  ..
  VERBOSE=1 make
}

package() {
  cd OpenSceneGraph-OpenSceneGraph-${pkgver}
  make -C build DESTDIR="${pkgdir}" install
  install -Dm 644 LICENSE.txt -t "${pkgdir}/usr/share/licenses/${pkgname}"
}

# vim: ts=2 sw=2 et:
